package ca.etsmtl.log430.lab3;

import java.util.Observable;

public class ListCoursesSucceded extends Communication{

	public ListCoursesSucceded(Integer registrationNumber, String componentName) {
		super(registrationNumber, componentName);
	}
	
	public void update(Observable thing, Object notificationNumber) {
		Menus menu = new Menus();
		Displays display = new Displays();
		Student myStudent = new Student();

		if (registrationNumber.compareTo((Integer)notificationNumber) == 0) {
			/*
			 * First we use a Displays object to list all of the students. Then
			 * we ask the user to pick a student using a Menus object.
			 */
			addToReceiverList("ListStudentsComponent");
			signalReceivers("ListStudentsComponent");
			myStudent = menu.pickStudent(CommonData.theListOfStudents.listOfStudents);
			/*
			 * If the user selected an invalid student, then a message is
			 * printed to the terminal.
			 */
			if (myStudent != null) {
				display.displayStudentCoursesTaken(myStudent);
			} else {
				System.out.println("\n\n *** Student not found ***");
			}
		}
		removeFromReceiverList("ListStudentsComponent");
	}
	

}
